package cn.iocoder.yudao.module.erp.dal.mysql.business.warehouse;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.business.warehouse.vo.WarehousePageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.business.warehouse.WarehouseDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 仓库 Mapper
 *
 * @author maxuxu
 */
@Mapper
public interface WarehouseMapper extends BaseMapperX<WarehouseDO> {

    default PageResult<WarehouseDO> selectPage(WarehousePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WarehouseDO>()
                .likeIfPresent(WarehouseDO::getName, reqVO.getName())
                .likeIfPresent(WarehouseDO::getProvinceText, reqVO.getProvinceText())
                .likeIfPresent(WarehouseDO::getCityText, reqVO.getCityText())
                .betweenIfPresent(WarehouseDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WarehouseDO::getId));
    }

    default WarehouseDO selectByName(String name){
        return selectOne(WarehouseDO::getName, name);
    }
}